#ifndef __RELAY__H__
#define __RELAY__H__

	#include <wiringPi.h>
	#include <stdio.h>
	#include <unistd.h>
	#include <pthread.h>
	#include <signal.h>
	#include <errno.h>

	#include "debug.h"

	enum switchState
	{
		ON,
		OFF,
	};
    enum thread_mode_e
    {
        modeDelay,
        modeCycle
    };

	struct thread_data_t
	{
        thread_mode_e mode;
		int seconds;
		enum switchState state;
		int _pin;
	};


	class gpioSwitch  
	{
	public:

		gpioSwitch(int _pin);
		~gpioSwitch();

		int set(enum switchState state);
		int set(enum switchState state,int seconds);
        int setCycle(int _time);
	private :
		int pin;
		enum switchState state;

		pthread_t switch_thread;
		pthread_attr_t switch_thread_attr;

		struct thread_data_t thread_data;
	};


#endif
